<?php
namespace app\common\model\feedback;

use think\Model;
use traits\model\SoftDelete;
/**
 *  代理反馈模型
 * Class FeekbackAgent
 * @package app\common\model\feekback
 */
class FeedbackAgent extends Model
{

    use SoftDelete;

    protected $name='feedback_agent';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    /**
     * 获取代理反馈列表
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function getList()
    {
        return $this->order(['createtime' => 'desc'])
            ->paginate(15, false, [
                'query' => \request()->request()
            ]);
    }

    /**
     * 获取反馈信息
     * @param $where
     * @return null|static
     * @throws \think\exception\DbException
     */
    public static function detail($where)
    {

        $filter = ['deletetime' => 0];
        if (is_array($where)) {
            $filter = array_merge($filter, $where);
        } else {
            $filter['id'] = (int)$where;
        }
        return static::get($filter);
    }

    /**
     * 更新用户备注
     * @param $data
     * @param $id
     * @return mixed
     */
    public function updateRemark($id,$data)
    {
        return $this->save(['remark'=>$data['remark'],'status'=>1],['id' => $id]);
    }

}